#ifndef _CSRMATRIX_H
#define _CSRMATRIX_H

#include "FluidSparseMatrix.h"

class CSRMatrix
{
public:
	std::vector<double> values;
	std::vector<int> columns;
	std::vector<int> rowIndex;
	int n;

	CSRMatrix();
	CSRMatrix(int numGridX, int numGridY, int numGridZ);
	void SetDim(int numGridX, int numGridY, int numGridZ);
	~CSRMatrix();
	void ConvertFromFluidSparseMatrix(const FLuidSparseMatrix& m, bool bSymmetric = false);
	void GetRow(int i, int& startIdx, int& numEntries);
	bool GetDiagonalElement(int i, int& index, double& value);
	bool GetElement(int i, int j, int& index, double& value);
	int GetNumNonZeroEntries()
	{
		return static_cast<int>(values.size());
	}
	bool IsSymmetric()
	{
		return isSymmetric;
	}
	void Transpose();
private:
	void build3DTo1DMap(const FLuidSparseMatrix& m);	
	int numX;
	int numY;
	int numZ;
	bool isSymmetric;
};
#endif